#define  _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int arr[100000] = { 0 };
int main()
{
    int n = 0, m = 0, i = 0, min = 0, j = 0, x = 0, y = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    for (i = 0; i < m; i++)
    {
        scanf("%d %d", &x, &y);
        for (j = x, min = arr[x]; j <= y; j++)
        {
            if (arr[j] < min)
                min = arr[j];
        }
        printf("%d\n", min);
    }
    return 0;
}